﻿
@{
    ViewData["Title"] = "参建单位人员统计";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}
@section styles
    {
    <environment names="Development">
        <link href="~/css/plugins/jqgrid/ui.jqgrid.css" rel="stylesheet" />
        <link href="~/js/plugins/select2/css/select2.css" rel="stylesheet" />
    </environment>
    <environment names="Staging,Production">
        <link rel="stylesheet" href="~/css/grid.min.css" asp-append-version="true" />
    </environment>
}
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>
                <a href="../Statistics/index">参建单位人员统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/ManagerStatis">参建单位管理人员统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/GroupWorkerStatis">参建单位施工人员统计</a>
                &nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/WorkerStatis">施工人员统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/AttendanceStatis">个人考勤统计</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Statistics/WorkerDateStatis">单位工时统计</a>
            </h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>



        <div class="ibox-content">
            <div class="form-group">
                <div class="row">
                    <div class="col-md-3">

                        <select id="CompanyId" name="CompanyId" class="form-control"></select>

                    </div>
                    <div class="col-md-3">

                        <select id="JobPositionTypeId" name="JobPositionTypeId" class="form-control"></select>
                    </div>
                    <div class="col-md-3">
                        <input id="txtSearchKey" type="text" class="input form-control" placeholder="员工姓名" />

                    </div>
                    <div class="col-md-3">

                    </div>
                </div>
                <div class="row">
                    <div class="col-md-3">
                        <select name="year" id="year"
                                class="form-control" placeholder="年">
                            <option value="2019" selected="selected">2019</option>
                            <option value="2020">2020</option>
                            <option value="2021">2021</option>
                            <option value="2022">2022</option>
                            <option value="2023">2023</option>
                            <option value="2024">2024</option>
                            <option value="2025">2025</option>
                            <option value="2026">2026</option>
                            <option value="2027">2027</option>
                            <option value="2028">2028</option>
                            <option value="2029">2029</option>
                        </select>
                    </div>
                    <div class="col-md-3">
                        <select name="month" id="month"
                                class="form-control" placeholder="月">
                            <option value="1" selected="selected">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                        </select>
                    </div>
                    @*<div class="col-md-3">

                        <select name="state" id="state"
                                class="form-control" placeholder="状态">
                            <option value="" selected="selected">全部</option>
                            <option value="1">启用</option>
                            <option value="0">停用</option>
                        </select>
                    </div>*@
                    <div class="col-md-3">
                        <span class="input-group-btn">
                            <button id="btnSearch" class="btn btn btn-primary" type="button"> <i class="fa fa-search"></i> 搜索</button>
                            <button id="btnExport" class="btn btn btn-primary" type="button"> 导出</button>
                        </span>
                    </div>
                </div>

                <div class="jqGrid_wrapper">
                    <table id="table_list"></table>
                    <div id="pager_list"></div>
                </div>

                <div id="jqGrid_Table">

                </div>
            </div>

        </div>
    </div>
</div>
@section scripts
    {
        <script src="~/js/plugins/jqgrid/jquery.jqGrid.js"></script>
        <script src="~/js/plugins/jqgrid/i18n/grid.locale-cn.js"></script>
        <script src="~/js/jqgrid-list.js"></script>
        <script src="~/js/json2.js"></script>
        <script src="~/js/base.js"></script>
        <script src="~/js/plugins/select2/js/select2.js"></script>
        <script src="~/js/BindSelect.js"></script>

    <environment names="Staging,Production">
        <script src="~/js/grid.min.js" asp-append-version="true"></script>

    </environment>




    <script>
  $("#btnExport").click(function () {
      window.open('/Xlsx/GetWorkerStatistic?CompanyId=' + $("#CompanyId").val() + '&JobPositionTypeId=' + $("#JobPositionTypeId").val() + '&name=' + $("#txtSearchKey").val() + '&year=' + $("#year").val() + '&month=' + $("#month").val() +'');

        });
      function GetSouce() {
              $.ajax({
                url: '@Url.Action("GetWorkerStatistic")',
                type: "GET",
                dataType: "json",
                async: true,
                  data: {
                      CompanyId: $("#CompanyId").val(),
                      JobPositionTypeId: $("#JobPositionTypeId").val(),
                      name: $("#txtSearchKey").val(),
                      year: $("#year").val(),
                      month: $("#month").val(),
                  },
                  success: function (data) {
                    var table = ('<table class="ui-jqgrid-htable ui-common-table table table-bordered">');
                    table += '<tr class="ui-jqgrid-labels" role="row">';
                    table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> 员工姓名</td>';
                    table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> 岗位名称</td>';
                      table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> 正常班工时</td>';
                      table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> 加班工时</td>';
                      table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> 累计工时</td>';
                    table += '</tr>';
                    for (var i = 0; i < data.length; i++) {
                        table += '<tr class="ui-jqgrid-labels" role="row">';
                        table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + data[i].workerName +'</td>';
                        table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + data[i].jobName + '</td>';
                        table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + data[i].totalHour + '</td>';
                        table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + data[i].addedHour + '</td>';
                        table += '<td role="columnheader" class="ui-th-column ui-th-ltr"> ' + data[i].allHour + '</td>';
                        table += '</tr>';
                    }
                    table += '</table>';
                    $("#jqGrid_Table").append(table);
                }
            });
        }

        $(document).ready(function () {
            BindSelect("JobPositionTypeId", "/JobPositionType/GetJobPositionTypes");
            BindSelect("CompanyId", "/Company/GetCompanys");
            var myDate = new Date();
            var year = myDate.getFullYear();
            //获取当前月
            var month = myDate.getMonth() + 1;
            $("#month").val(month);
            $("#year").val(year);
            //BindSelect("orginationName", "/Company/GetCompanys");
            GetSouce();
            $("#btnSearch").click(function () {
                $("#jqGrid_Table").html("");
                GetSouce();
            });
        });

        //BindSelect("orginationName", "/Organization/GetOrganizations");
        //BindSelect("JobId", "/JobPositionType/GetJobPositionTypes");

        //function searchData() { //搜索
        //    GetSouce();
        //    //var json = {
        //    //    company: $("#company").val(),
        //    //    job: $("#job").val(),
        //    //    state: $("#job").val(),
        //    //};
        //    //XPage.Search(json);
        //}


        @*$(document).ready(function() {
            var config = {
                title: '公司列表',
                url: '@Url.Action("GetListWithPager")',
                colNames: ['参建单位', '管理人员', '施工人员', '技术人员', '其他', '状态'],
                colModel: [
                    { name: 'id', index: 'id', width: 60, key: true, hidden: true },
                    { name: 'organizationName', index: 'organizationName', width: 60 },
                    { name: 'organizationName', index: 'organizationName', width: 60 },
                    { name: 'address', index: 'address', width: 60 },
                    { name: 'contact', index: 'contact', width: 60 },
                    { name: 'stats', index: 'stats', width: 60 },
                ]
            };
            JucheapGrid.Load(config);
            $("#btnSearch").bind("click", searchData);

        });*@
    </script>
}